package com.smart.controller.app;

import java.util.List;
import com.smart.util.Messages;
import com.smart.entity.SsSite;
import javax.annotation.Resource;
import lombok.AllArgsConstructor;
import io.swagger.annotations.Api;
import com.smart.service.SsSiteService;
import io.swagger.annotations.ApiOperation;
import com.smart.controller.BaseController;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author lgb
 * @date 2020年6月12日 下午5:10:56
 * Copyright (C) 深圳工勘科技
 * @说明: 工地管理controller
 **/
@AllArgsConstructor
@RestController("appSsSiteController")
@RequestMapping("/app/sssite")
@Api(value="sssite",tags="智慧工地-工地管理")
public class SsSiteController extends BaseController{

	@Resource
	private SsSiteService ssSiteService;
	
	/**
	 * @param pageNum
	 * @param pageSize
	 * @return 获取工地分页数据
	 **/
	@GetMapping(value="/page")
	@ApiOperation(value="app=>获取工地分页",notes="app获取工地分页")
	public Messages<List<SsSite>> page(
		   @RequestParam(name="pageNum")Integer pageNum,
		   @RequestParam(name="pageSize")Integer pageSize){
		IPage<SsSite> page = ssSiteService.findPage(pageNum,pageSize);
	    return Messages.success(page.getRecords());
	}
	
	@GetMapping(value="/get")
	@ApiOperation(value="app=>app获取工地详情",notes="app获取工地详情")
	public Messages<SsSite> get(
			@RequestParam(name="siteId",required=true)Integer siteId){
		SsSite site = ssSiteService.findById(siteId);
		return Messages.success(site);
	}
	
	/**
	 * @param pageNum
	 * @param pageSize
	 * @return 获取工地分页数据
	 **/
	@GetMapping(value="/list")
	@ApiOperation(value="app=>获取工地列表",notes="app获取工地列表")
	public Messages<List<SsSite>> list(){
		List<SsSite> list = ssSiteService.findAll();
	    return Messages.success(list);
	}
}